package com.strato.mvc.api.v1_0_0.control.impl.matcher;

import com.strato.mvc.api.v1_0_0.control.PathVariableCollector;

public class ConstantMatcher implements Matcher {

	private String constant;

	public ConstantMatcher(String constant){
		this.constant=constant;
	}
	
	@Override
	public int match(String part, PathVariableCollector pvc) {
		if("*".equals(constant)||"**".equals(constant)){
			return MATCH_SUCCEDENT;
		}
		if(part.equals(constant)){
			return MATCH;
		}
		return NOT_MATCH;
	}

	@Override
	public boolean conflicts(Matcher matcher) {
		return false;
	}

	@Override
	public boolean mequals(Matcher matcher) {
		if(matcher instanceof ConstantMatcher){
			ConstantMatcher cm=(ConstantMatcher) matcher;
			return cm.constant.equals(this.constant);
		}
		return false;
	}

}
